import 'package:backend.core/core/domain/entities/google_play/google_play_transaction.dart';
import 'package:backend.core/core/domain/entities/google_play/google_play_transaction_revocation_info.dart';
import 'package:equatable/equatable.dart';

class GooglePlayOneTimePurchasedItemTransaction extends Equatable
    implements GooglePlayTransaction {
  const GooglePlayOneTimePurchasedItemTransaction({
    required this.orderId,
    required this.time,
    required this.googlePlayUserId,
    required this.purchaseToken,
    required this.purchaseItemSku,
    required this.promotional,
    required this.test,
    required this.revocationInfo,
  });

  @override
  final String orderId;

  @override
  final String googlePlayUserId;

  @override
  final String purchaseToken;

  @override
  final String purchaseItemSku;

  @override
  final bool test;

  @override
  final GooglePlayTransactionRevocationInfo? revocationInfo;

  @override
  final DateTime time;

  final bool promotional;

  @override
  List<Object?> get props {
    return [
      orderId,
      time,
      googlePlayUserId,
      purchaseToken,
      purchaseItemSku,
      promotional,
      test,
      revocationInfo,
    ];
  }

  GooglePlayOneTimePurchasedItemTransaction copyWith({
    String Function()? orderId,
    DateTime Function()? time,
    String Function()? googlePlayUserId,
    String Function()? purchaseToken,
    String Function()? purchaseItemSku,
    bool Function()? promotional,
    bool Function()? test,
    GooglePlayTransactionRevocationInfo? Function()? revocationInfo,
  }) {
    return GooglePlayOneTimePurchasedItemTransaction(
      orderId: orderId == null ? this.orderId : orderId(),
      time: time == null ? this.time : time(),
      googlePlayUserId: googlePlayUserId == null ? this.googlePlayUserId : googlePlayUserId(),
      purchaseToken: purchaseToken == null ? this.purchaseToken : purchaseToken(),
      purchaseItemSku: purchaseItemSku == null ? this.purchaseItemSku : purchaseItemSku(),
      promotional: promotional == null ? this.promotional : promotional(),
      test: test == null ? this.test : test(),
      revocationInfo: revocationInfo == null ? this.revocationInfo : revocationInfo(),
    );
  }
}
